package com.lank.gateway.config.service.impl;

import com.lank.gateway.enums.GatewayBusinessEnum;
import com.lank.gateway.exception.GatewayBusinessException;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.server.authorization.ServerAccessDeniedHandler;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;


/**
 * @author 郑海宾
 * @since 2020/7/24 下午4:02 星期五
 */
@Component
public class CustomAccessDeniedHandler implements ServerAccessDeniedHandler {
    @Override
    public Mono<Void> handle(ServerWebExchange exchange, AccessDeniedException exception) {
        return Mono.error(new GatewayBusinessException(GatewayBusinessEnum.ACCESS_DENIED_EXCEPTION));
    }
}
